package com.android.androidbigwork.frames;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import com.android.androidbigwork.R;
import com.android.androidbigwork.adapter.Demo_List_Adapter;
import com.android.androidbigwork.entity.Item_Share;
import com.android.androidbigwork.utils.MyCallBack;
import com.android.androidbigwork.utils.RequestUtils;

import java.util.ArrayList;
import java.util.List;

public class My extends Fragment {
    private static final String url =
            "http://39.108.183.17:8080/getmyShare";

    private MyCallBack myCallBack;
    private Demo_List_Adapter my_list_adapter;

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View v = inflater.inflate(R.layout.my_layout,container,false);
        return v;
    }

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);

        List<Item_Share> list = new ArrayList<>();
        Integer[] res= new Integer[6];
        res[0]=R.layout.my_item;
         res[1] = R.id.my_item_header_photo;
         res[2] = R.id.my_item_name;
        res[3] = R.id.my_item_message;
        res[4] = R.id.my_grid_layout;

         my_list_adapter =
                new Demo_List_Adapter(this.getContext(),R.layout.my_layout,list,this);
        my_list_adapter.setFlag(false);
        my_list_adapter.setResLayoutId(res);
         myCallBack = new MyCallBack(this);
        myCallBack.setFragment(this);
        myCallBack.setDemo_list_adapter(my_list_adapter);
        myCallBack.setFlag(false);
        RequestUtils.flag = false;
        RequestUtils.getShares(url,myCallBack);
    }

}
